﻿using AyFrame.Dto;
using AyFrame.IServices;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AyFrame.WebApi.Controllers.Sys
{
    [Route("api/[controller]")]
    public class GatewayController : BaseController
    {
        readonly IGatewayService _ocelotSer;
        public GatewayController(IGatewayService gatewayService)
        {
            _ocelotSer = gatewayService;
        }

        [Route("add"), HttpPost]
        public async Task<IActionResult> Add(OcelotGatewayCreateDto dto)
        {
            return Success(await _ocelotSer.Add(UserId, dto));
        }

        [Route("update"), HttpPut]
        public async Task<IActionResult> Update(OcelotGatewayUpdateDto dto)
        {
            return Success(await _ocelotSer.Update(UserId, dto));
        }

        [Route("search"), HttpPost]
        public async Task<IActionResult> Search(OcelotSearchRequest req)
        {
            return Success(await _ocelotSer.Search(req));
        }
    }
}
